
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <style>
        .dialog{
            width: 500px;
            height: 200px;
            border: solid 1px #b5b0b0;
            border-radius: 5px;
            position: absolute;
            left: 30%;
            bottom: 30%;
            background: #eee;
            line-height: 40px;
            text-align: center;
            display: none;
            font-size:16px;
        }
        body{
            text-align: center;
        }
        table{
            margin: auto;
        }
    </style>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery_1.12.4.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#addInfo").click(function () {
                window.location.href="addInfo.jsp";
            });

            $("#update").click(function () {
                var stuId = $("#hidden").val();
                window.location.href="/student?action=getUpdateInfo&id="+stuId;
            });

            $("#del").click(function () {
                var stuId = $("#hidden").val();
               // window.location.href="deleteInfo.jsp?id="+stuId;//有错误
                $(".dialog").show(200);
                $("#btn_del").on("click",function () {
                    window.location.href="/student?action=deleteInfo&id="+stuId;
                });
                $("#btn_return").on("click",function () {
                    $(".dialog").css("display","none");
                })
            });
        });
    </script>
</head>
<body>
    <h2>学生信息管理</h2>
   <input type="button" value="添加信息" id="addInfo"><br>
   <table cellspacing="0" border="1">
        <tr>
            <td>姓名</td>
            <td>年龄</td>
            <td>性别</td>
            <td>地址</td>
            <td>学校</td>
            <td colspan="2">操作</td>
        </tr>
        <c:forEach items="${list}" var="studentPo">
            <tr>
                <td>${studentPo.name}<input type="hidden" id="hidden" value="${studentPo.id}"></td>
                <td>${studentPo.age}</td>
                <td>${studentPo.sex}</td>
                <td>${studentPo.address}</td>
                <td>${studentPo.school}</td>
                <td><input type="button" value="修改" id="update"></td>
                <td><input type="button" value="删除" id="del"></td>
            </tr>
        </c:forEach>
   </table>
    <div class="dialog">
        <h3>提示：</h3>
        <p>是否确认删除？<br/><br/>
            <input type="button" id="btn_del" value="删除">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" id="btn_return" value="取消">
        </p>
    </div>
</body>
</html>
